const { defineConfig } = require("@vue/cli-service");
let env = process.env.VUE_APP_ENV;

const path = require("path");
function resolve(dir) {
  return path.join(__dirname, dir);
}
module.exports = defineConfig({
  publicPath: ".",
  transpileDependencies: true,
  lintOnSave: false,
  outputDir: env === "test" ? "testDist" : "dist",
  devServer: {
    //代理请求
    port: 8080,
    proxy: {
      "/api": {
        target: process.env.VUE_APP_BASEURL, //http目标根地址
        pathRewrite: {
          "^/api": "",
        },
      },
    },
  },
  chainWebpack: (config) => {
    config.resolve.alias
      .set("%", resolve("src"))
      .set("assets", resolve("src/assets"))
      .set("component", resolve("src/components"))
      .set("static", resolve("src/static"));
  },
});
